-- physics_attack
-- create by panyl
-- 物理攻击

return {
    apply = function(source, target, skillId, round, para, value)
        local damage = value[1];
        local cure = value[2];
        local debuff = value[3];
        target:receiveDamage(damage);
        trace("physics_attack", "%s 受到 %d 点伤害，当前生命值 %d",
            target:getName(), damage, target:queryAttrib("hp"));

        -- 尝试吸血
        if cure > 0 then
            source:addAttrib("hp", cure);
            trace("physics_attack", "%s 回复 %d 点生命，当前生命值 %d", source:getName(), cure, source:queryAttrib("hp"));
        end

        if #debuff > 0 then
            -- 记录属性
            PropM.recordDebuff(target, debuff);
        end

        -- 尝试附加特殊属性
        SkyPropM.triggerProp(source, "attack_sc_prop", {["skillId"] = skillId, ["target"] = target})

        return { ["damage"] = damage, ["cure"] = cure, };
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { tonumber(arr[1]), };
    end,

    getDetail = function(para)
        local desc = getLocStr("shipskill_physics_attack");

        local value = para[1] / 10;
        desc = string.format(desc, value);

        return desc;
    end,

    getShipgunDetail = function(para, rate)
        -- 飞艇主炮描述
        local desc = getLocStr("shipskill_physics_attack2");
        local value = para[1] / 10;
        desc = string.format(desc, value);

        return desc;
    end,
};
